package com.zian.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum LockedEnum {
    // 锁定
    LOCKED(1,"已锁定"),
    // 未锁定
    UNLOCKED(0,"未锁定");

    @JsonValue
    @EnumValue
    private final int code;
    private final String name;

    LockedEnum(int code, String name){
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(int code){
        for(LockedEnum lockedEnum : LockedEnum.values()){
            if(lockedEnum.getCode() == code){
                return lockedEnum.getName();
            }
        }
        return null;
    }

    public static LockedEnum getByCode(int code){
        for(LockedEnum lockedEnum : LockedEnum.values()){
            if(lockedEnum.getCode() == code){
                return lockedEnum;
            }
        }
        return null;
    }

}
